function [image_scan_pseudo, mask_scan_pseudo]  = deform_using_transformix_toolbox(patient, scan_folder);
    
    %|  Deform reference image using Transformix; 
    %|  An Elastix 'TransformParameters.0.txt' file is created (using the originial Elastix
    %|  registration as a template), so that the deformation can be
    %|  performed by Transformix.  There are many easy ways to do this
    %|  (3dinterp in Matlab for instance), but I found Transformix to be the
    %|  most accurate in deforming an image. 
    %| 
    %|  The code is ran twice - once on the image and once on the mask, as
    %|  transformix requires that  '(FinalBSplineInterpolationOrder 0)' is set
    %|  for a binary (mask) image).
    
    %|  Please check the transformix logs in each case for errors - usually
    %|  with filenames/folder paths (try and use underscores instead of
    %|  spaces).
    %|  Please see the Elastix manual for reference -  Chapter 4, & Section 5.4
    %------------------------------------------------------------------------
    %|      Dependancies;  
    %|                  generate_tranformix_parameters_toolbox
    %|                  generate_tranformix_parameters_mask_toolbox   
    %|                 
    %------------------------------------------------------------------------
    %   This file is part of the
    %   5D-Novel4DCT Toolbox  ("Novel4DCT-Toolbox")
    %   DH Thomas, Ph.D
    %   University of California, Los Angeles
    %   Contact: mailto:dhthomas@mednet.ucla.edu
    %------------------------------------------------------------------------
    % $Author: DHThomas $	$Date: 2014/04/01 10:23:59 $	$Revision: 0.1 $

    scan = patient.ref;% use 1st registration as a template;
    generate_tranformix_parameters_toolbox(patient, scan_folder);
    moving=['"' patient.folder_static '/' patient.static_image_name '"']
%     elastix_program_folder = '"C:/Program Files/elastix';
    transform_param=['"' scan_folder '/Model_TransformParameters.0.txt' '"']
    transformix_cmd= ['"' patient.elastix_root_folder '/transformix" -in '  '"' moving '"' ' -out ' '"' scan_folder '"' ' -tp ' transform_param]
    % transformix_cmd=['transformix -def all -out ' '"' out '"' ' -tp ' transform_param]
    [status result]=system(transformix_cmd);
        
    image_scan_pseudo = metaImageRead([scan_folder '/result']);
    metaImageWrite(image_scan_pseudo,[scan_folder '/' sprintf('pseudo_scan%d', scan)],'ElementSpacing', [1 1 1]);

    generate_tranformix_parameters_mask_toolbox(patient, scan_folder);
    transform_param_mask=['"' scan_folder '/Model_TransformParameters_mask.0.txt' '"']
    mask_filename = [patient.folder_static    '/' patient.static_mask_name];
    transformix_cmd_mask = ['"' patient.elastix_root_folder '/transformix" -in '  '"' mask_filename '"' ' -out ' '"' scan_folder '"' ' -tp ' transform_param_mask]
    [status result]=system(transformix_cmd_mask);
    mask_scan_pseudo = metaImageRead([scan_folder '/result']);
    metaImageWrite(mask_scan_pseudo,[scan_folder '/' sprintf('pseudo_mask%d', scan)],'ElementSpacing', [1 1 1]);
